<?php 
	/*
	Plugin Name: Footfall Growth Calculator
	Plugin URI: http://www.swofmedia.co.uk
	Description: Plugin for displaying Footfall Growth Calculator
	Author: Andrew Frazier
	Version: 3.0
	Author URI: http://www.swofmedia.co.uk

	Copyright 2013  Swofmedia  (email : info@swofmedia.co.uk)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License, version 2, as 
    published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

	*/


// Add Shortcode
function ff_growth_calculator() {
	$options = get_option( 'growth_calculator_opt' );
	$theLink = $options['theLink'];
	$theWindow = $options['newWindow'];
	$thePosition = $options['position'];
	$theEmail = $options['emailAddress'];
	$thePhone = $options['thePhone'];
	
	if($thePosition == 'popup')
		{
			$output = '<a href="calc.php" onclick="ttmb.box.show({iframe:\''.plugins_url( 'calc.php' , __FILE__ ).'\',width:855,height:590});return false;"><img src="'.plugins_url( 'img/calculator-button-icon.png' , __FILE__ ).'" title="'. __( 'Open Growth Calculator','ff-growth-calculator').'" height="42" width="42" alt="'. __( 'Open Growth Calculator','ff-growth-calculator').'" /></a>';
			return $output;
		}
	else
		{ ?>
			<div id="outer">
			<div id="bgTop"></div>
			<div id="bgMid">
			  <div id="bgMain">
				<img src="<?php echo plugins_url( 'img/logo.gif' , __FILE__ ); ?>" width="138" height="50" alt="Experian" />
				<div id="innerTop">
				  <div id="heading">
					<a href="javascript:void(0)" id="close" class="yellowButton"><?php _e( 'Close','ff-growth-calculator'); ?></a>
					<img src="<?php echo plugins_url( 'img/calc.png' , __FILE__ ); ?>" width="139" height="131" alt="<?php _e( 'Calculator','ff-growth-calculator'); ?>" />
					<h1><?php _e( 'Step 1: Using performance data to grow sales','ff-growth-calculator'); ?></h1>
					<h2><?php _e( 'Enter your statistics, or your nearest guestimate','ff-growth-calculator'); ?></h2>
				  </div>
				  <div class="fldset">
					<p class="field">
						<label for="x9f"><?php _e( 'Average Transaction Value (ATV)','ff-growth-calculator'); ?></label>
					  <input type="text" id="x9f" value="50" maxlength="6" />
					  <a href="javascript:void(0)" class="tooltip" title="<?php _e( 'Please enter the average value of your transactions','ff-growth-calculator'); ?>"><img src="<?php echo plugins_url( 'img/tooltip.gif' , __FILE__ ); ?>" width="18" height="18" alt="<?php _e( '?','ff-growth-calculator'); ?>" /></a>
					</p><!-- /field -->
					<p class="field fieldright">
						<label for="x10f"><?php _e( 'Footfall per Week per Store','ff-growth-calculator'); ?></label>
					  <input type="text" id="x10f" value="1000"  maxlength="6" />
					  <a href="javascript:void(0)" class="tooltip" title="<?php _e( 'Please enter the weekly Footfall for each store','ff-growth-calculator'); ?>"><img src="<?php echo plugins_url( 'img/tooltip.gif' , __FILE__ ); ?>" width="18" height="18" alt="<?php _e( '?','ff-growth-calculator'); ?>" /></a>
					</p><!-- /field -->
				  </div><!-- /fldset -->
				  <div class="fldset">
					<p class="field">
						<label for="x11f"><?php _e( 'Current Conversion Rate (%)','ff-growth-calculator'); ?></label>
					  <input type="text" id="x11f" value="20" maxlength="3" />
					  <a href="javascript:void(0)" class="tooltip" title="<?php _e( 'Please enter the current percentage of conversion (1-100)','ff-growth-calculator'); ?>"><img src="<?php echo plugins_url( 'img/tooltip.gif' , __FILE__ ); ?>" width="18" height="18" alt="<?php _e( '?','ff-growth-calculator'); ?>" /></a>
					</p><!-- /field -->
					<p class="field fieldright">
						<label for="x15f"><?php _e( 'Number of Stores','ff-growth-calculator'); ?></label>
					  <input type="text" id="x15f" value="20" maxlength="6" />
					  <a href="javascript:void(0)" class="tooltip" title="<?php _e( 'Please enter the number of stores','ff-growth-calculator'); ?>"><img src="<?php echo plugins_url( 'img/tooltip.gif' , __FILE__ ); ?>" width="18" height="18" alt="<?php _e( '?','ff-growth-calculator'); ?>" /></a>
					</p><!-- /field -->
				  </div><!-- /fldset -->
				  <p id="submitField">
					<span id="BxC"><?php _e( 'Checkpoint: based on your entries, your average transactions per store per week are','ff-growth-calculator'); ?> <strong>200</strong></span>
					<a href="javascript:void(0)" class="yellowButton"><?php _e( 'Click and go to step 2','ff-growth-calculator'); ?><img src="<?php echo plugins_url( 'img/blueArrowOnWhitecircle.png' , __FILE__ ); ?>" class="blueArrowOnWhite" height="19" width="19" alt="<?php _e( 'Arrow','ff-growth-calculator'); ?>" /></a>
				  </p>
				</div><!-- /innerTop -->
				<div id="innerBot">
					<div id="ibArrow"><img src="<?php echo plugins_url( 'img/innerbotarrow.png' , __FILE__ ); ?>" width="31" height="21" alt="" /></div>
				  <div id="ibLeft">
					<div id="iblHead">
						<h2><?php _e( 'Step 2: Make a minor change to see a huge return','ff-growth-calculator'); ?></h2>
					  <h3><?php _e( 'Drag to change','ff-growth-calculator'); ?></h3>
					</div><!-- /ibHead -->
					<div class="slideField">
					  <label for="dlSlider1"><?php _e( 'Improved Conversion Rate (%)','ff-growth-calculator'); ?> <span><?php _e( '(Change by percentage point)','ff-growth-calculator'); ?></span></label>
					  <div class="sliderBarEmpty">
						<div class="sliderBarFull"></div>
						<div id="dlSlider1" class="dlSlider">
						  <a href="javascript:void(0)" class="bar handle" role="slider" aria-labelledby="sliderLabel" aria-valuemin="0" aria-valuemax="1" aria-valuenow="5" aria-valuetext="0"><span>1.0%</span></a>
						</div>
					  </div><!-- /#sliderBarEmpty -->
					  <div class="clearBoth"></div>
					</div><!-- /slideField -->
					<div class="slideField">
					  <label for="dlSlider2"><?php _e( 'Improved Footfall by (%)','ff-growth-calculator'); ?> <span><?php _e( '(Change by percentage point)','ff-growth-calculator'); ?></span></label>
					  <div class="sliderBarEmpty">
						<div class="sliderBarFull"></div>
						<div id="dlSlider2" class="dlSlider">
						  <a href="javascript:void(0)" class="bar handle" role="slider" aria-labelledby="sliderLabel" aria-valuemin="0" aria-valuemax="1" aria-valuenow="5" aria-valuetext="0"><span>1.0%</span></a>
						</div>
					  </div><!-- /#sliderBarEmpty -->
					  <div class="clearBoth"></div>
					</div><!-- /slideField -->
					<div class="slideField">
					  <label for="dlSlider3"><?php _e( 'Improve ATV by (%)','ff-growth-calculator'); ?> <span><?php _e( '(Change by percentage point)','ff-growth-calculator'); ?></span></label>
					  <div class="sliderBarEmpty">
						<div class="sliderBarFull"></div>
						<div id="dlSlider3" class="dlSlider">
						  <a href="javascript:void(0)" class="bar handle" role="slider" aria-labelledby="sliderLabel" aria-valuemin="0" aria-valuemax="1" aria-valuenow="5" aria-valuetext="0"><span>1.0%</span></a>
						</div>
					  </div><!-- /#sliderBarEmpty -->
					  <div class="clearBoth"></div>
					</div><!-- /slideField -->
				  </div><!-- /ibLeft -->
				  <div id="ibRight">
					<div id="ibrHead">
						<h2><?php _e( 'Step 3: See results','ff-growth-calculator'); ?></h2>
					  <h3><?php _e( 'Incremental revenue growth','ff-growth-calculator'); ?></h3>
					</div><!-- /ibrHead -->
					<div id="ibrHead2">
						<p class="row1">
						<span class="col1"><strong>&nbsp;</strong></span>
						<span><strong><?php _e( 'Per Store','ff-growth-calculator'); ?></strong></span>
						<span><strong><?php _e( 'Total','ff-growth-calculator'); ?></strong></span>
					  </p>
					  <p>
						<span class="col1"><strong><em><?php _e( 'Weekly Revenue Increase','ff-growth-calculator'); ?></em></strong></span>
						<span><strong id="x24f">0</strong></span>
						<span><strong id="x24h">0</strong></span>
					  </p>
					  <p>
						<span class="col1"><strong><em><?php _e( 'Annual Revenue Increase','ff-growth-calculator'); ?></em></strong></span>
						<span><strong id="x26f">0</strong></span>
						<span><strong id="x26h">0</strong></span>
					  </p>
					</div><!-- /ibrHead2 -->
					<p id="ibrHead3">
						<strong><?php _e( '% Revenue Growth','ff-growth-calculator'); ?></strong>
					  <img src="<?php echo plugins_url( 'img/up.gif' , __FILE__ ); ?>" width="36" height="36" alt="Up" />
					  <span id="x28h">0%</span>
					</p>
				  </div><!-- /ibRight -->
				</div><!-- /innerBot -->
				<p id="footer"><?php _e( 'This calculator demonstrates how by focusing on marginal improvements in performance, you can achieve formidable revenue uplift. But with Site Analytics from Experian FootFall, visitor counting is just the start. Imagine being able to extend this analysis to include personnel or energy costs for a store and ranking sites by type, size and geography to gain further insights. By acting on this valuable performance information you can transform revenue, profits and average transaction values!','ff-growth-calculator'); ?></p>
				<p id="footer2">
					<a href="<?php echo $theLink ?>" id="cta" <?php if($theWindow == 1){?>target="blank" title="<?php _e('Opens in a new browser window','ff-growth-calculator');?>" <?php } ?> class="yellowButton"><?php _e( 'Get in touch to calculate your performance potential more accurately','ff-growth-calculator'); ?><img src="<?php echo plugins_url( 'img/blueArrowOnWhitecircle.png' , __FILE__ ); ?>" class="blueArrowOnWhite" height="19" width="19" alt="<?php _e( 'Arrow','ff-growth-calculator'); ?>" /></a> 
					<span><?php _e( 'For a free consultation','ff-growth-calculator'); ?>, <?php echo $thePhone ?><br /><?php _e( 'email','ff-growth-calculator'); ?>: <a href="mailto:<?php echo $theEmail ?>?subject=Calculate growth"><?php echo $theEmail ?></a></span>
				</p>
			  </div><!-- /bgMain -->
			</div><!-- /bgMid -->
			<div id="bgBot"></div>
		  </div><!-- /outer -->
		<?php }
}
add_shortcode( 'growth_calculator', 'ff_growth_calculator' );

add_action( 'wp_enqueue_scripts', 'register_stylesheets' );
function register_stylesheets() {
	$options = get_option( 'growth_calculator_opt' );
	$thePosition = $options['position'];
	if($thePosition == 'popup')
		{
			wp_register_style( 'ff_growth_calculator', plugins_url( 'css/ttmbox.css' , __FILE__ ) );
		}
	else
		{
			wp_register_style( 'ff_growth_calculator', plugins_url( 'css/calc.css' , __FILE__ ) );
		}
	wp_enqueue_style( 'ff_growth_calculator' );
}

add_action( 'wp_enqueue_scripts', 'register_script' );
function register_script() {
	$options = get_option( 'growth_calculator_opt' );
	$thePosition = $options['position'];
	if($thePosition == 'popup')
		{
			wp_enqueue_script( 'my-js', plugins_url("js/ttmbox.js", __FILE__), false );
		}
	else
		{
			wp_enqueue_script( 'my-js', plugins_url("js/calculator.js", __FILE__), false );
		}
}

function growth_calculator_init() {
	$plugin_dir = basename(dirname(__FILE__)) . '/languages/';
	load_plugin_textdomain( 'ff-growth-calculator', false, $plugin_dir );
}
add_action('plugins_loaded', 'growth_calculator_init');

/* =====  OPTIONS PAGE ===== */
require('ff_options.php');